package com.cy.ppj.service.wj.impl;

import com.cy.ppj.comm.utils.CommonUtils;
import com.cy.ppj.dao.mapper.wj.WsOrderMapper;
import com.cy.ppj.model.PageBean;
import com.cy.ppj.model.query.wj.WsOrderAdminListQuery;
import com.cy.ppj.model.vo.wj.WsOrderAdminListVO;
import com.cy.ppj.service.BaseService;
import com.cy.ppj.service.wj.WsOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 万税贷询单 service
 * @Author tanyilin
 * @Date 2019/6/6 14:36
 */
@Service
public class WsOrderServiceImpl extends BaseService implements WsOrderService {

    @Autowired
    private WsOrderMapper wsOrderMapper;

    @Override
    public PageBean<WsOrderAdminListVO> selectWsOrderAdminList(WsOrderAdminListQuery query) {

        int total = wsOrderMapper.selectWsOrderAdminListCount(query);
        List<WsOrderAdminListVO> list = new ArrayList<>();
        if(total > 0) {
            query.startPage();
            list = wsOrderMapper.selectWsOrderAdminList(query);
            list.stream().forEach(w -> {
                w.setSexText(CommonUtils.isEmpty(w.getSex()) ? null : w.getSex().getText());
            });
        }

        return new PageBean<>(list, total);
    }
}
